<template>
  <div class="app-container">
    <!-- 基本信息 -->
    <div class="titleLineGreen">基本信息</div>
    <div class="info flex">
      <el-image
        class="info_avatar"
        :src="
          info.avatar ? info.avatar : require('@/assets/images/head_img.png')
        "
        :preview-src-list="[info.avatar]"
      ></el-image>
      <div class="info_right">
        <!-- 教师信息 -->
        <div class="info_teacherinfos">
          <div class="flex info_teacherinfo_line1">
            <div class="info_teacherinfo_line_item flex">
              <el-tooltip
                class="item"
                effect="dark"
                :content="info.name"
                placement="top-start"
              >
                <div class="info_teacherinfo_line_item_nickname overtxt">
                  {{ info.name }}
                </div>
              </el-tooltip>

              <img
                v-if="info.sex == 1"
                class="sex"
                src="@/assets/images/sex_women.png"
                alt=""
              />
              <img
                v-else
                class="sex"
                src="@/assets/images/sex_man.png"
                alt=""
              />
            </div>
            <el-tooltip
              class="item"
              effect="dark"
              :content="info.branch_name"
              placement="top-start"
            >
              <div class="info_teacherinfo_line_item overtxt">
                学院: {{ info.branch_name }}
              </div>
            </el-tooltip>

            <div class="info_teacherinfo_line_item overtxt">
              工号: {{ info.user_name }}
            </div>
          </div>
          <div class="flex info_teacherinfo_line2">
            <div
              class="info_teacherinfo_line1_rate info_teacherinfo_line_item flex"
            >
              <span>评分:</span>
              <el-rate
                disabled
                show-score
                text-color="#ff9900"
                score-template="{value}分"
                :value="info.teacherStar ? info.teacherStar.toFixed(1) : 0"
              ></el-rate>
            </div>
            <div class="info_teacherinfo_line_item overtxt">
              身份证: {{ info.id_card ? info.id_card : "--" }}
            </div>
            <div class="info_teacherinfo_line_item overtxt">
              手机号: {{ info.tel ? info.tel : "--" }}
            </div>
          </div>
        </div>
        <!-- 数据卡片 -->
        <div class="info_dataCards flex">
          <div class="info_dataCard" style="width: 320px; margin: 0 0 0 0px">
            <!-- 数据卡片的顶行 -->
            <div class="info_dataCard_topLine flex">
              <div
                class="info_dataCard_topLine_point"
                style="background: rgba(67, 218, 43, 1)"
              ></div>
              <div class="info_dataCard_topLine_lable">当前负责</div>
            </div>
            <!-- 数据卡片数据行 -->
            <div class="info_dataCard_dateLine info_dataCard_dateLine1 flex">
              <div class="info_dataCard_dateLine_item">
                <div class="info_dataCard_dateLine_item_lable">主讲课程</div>
                <div class="info_dataCard_dateLine_item_value">
                  {{
                    responsibleData.principalNum
                      ? responsibleData.principalNum
                      : 0
                  }}
                </div>
              </div>
              <div class="info_dataCard_dateLine_item">
                <div class="info_dataCard_dateLine_item_lable">辅助课程</div>
                <div class="info_dataCard_dateLine_item_value">
                  {{ responsibleData.helpNum ? responsibleData.helpNum : 0 }}
                </div>
              </div>
              <div class="info_dataCard_dateLine_item">
                <div class="info_dataCard_dateLine_item_lable">负责工作站</div>
                <div class="info_dataCard_dateLine_item_value">
                  {{
                    responsibleData.workstationNum
                      ? responsibleData.workstationNum
                      : 0
                  }}
                </div>
              </div>
            </div>
          </div>
          <div class="info_dataCard" style="width: 500px; margin: 0 0 0 24px">
            <!-- 数据卡片的顶行 -->
            <div class="info_dataCard_topLine flex">
              <div
                class="info_dataCard_topLine_point"
                style="background: rgba(44, 172, 255, 1)"
              ></div>
              <div class="info_dataCard_topLine_lable">
                工作数据 <span>(本学期/历史)</span>
              </div>
            </div>
            <!-- 数据卡片数据行 -->
            <div class="info_dataCard_dateLine info_dataCard_dateLine2 flex">
              <div class="info_dataCard_dateLine_item">
                <div class="info_dataCard_dateLine_item_lable">优秀率</div>
                <div class="info_dataCard_dateLine_item_value">
                  {{
                    workData && workData.goodPer
                      ? workData.goodPer + "%"
                      : "--"
                  }}<span></span>
                </div>
              </div>
              <div class="info_dataCard_dateLine_item">
                <div class="info_dataCard_dateLine_item_lable">平均成绩</div>
                <div class="info_dataCard_dateLine_item_value">
                  {{
                    workData && workData.avgScore
                      ? workData.avgScore.toFixed(2)
                      : "--"
                  }}<span v-if="workData && workData.hisAvgScore"
                    >/{{
                      workData && workData.hisAvgScore
                        ? workData.hisAvgScore.toFixed(2)
                        : "--"
                    }}</span
                  >
                </div>
              </div>
              <div class="info_dataCard_dateLine_item">
                <div class="info_dataCard_dateLine_item_lable">批卷数</div>
                <div class="info_dataCard_dateLine_item_value">
                  {{
                    workData && workData.examMarkNum
                      ? workData.examMarkNum
                      : "--"
                  }}<span v-if="workData && workData.totalExamMarkNum"
                    >/{{
                      workData && workData.totalExamMarkNum
                        ? workData.totalExamMarkNum
                        : "--"
                    }}</span
                  >
                </div>
              </div>
              <div class="info_dataCard_dateLine_item">
                <div class="info_dataCard_dateLine_item_lable">申请处理</div>
                <div class="info_dataCard_dateLine_item_value">
                  {{ workData && workData.applyNum ? workData.applyNum : "--"
                  }}<span v-if="workData && workData.TotalApplyNum"
                    >/{{
                      workData && workData.TotalApplyNum
                        ? workData.TotalApplyNum
                        : "--"
                    }}</span
                  >
                </div>
              </div>
              <div class="info_dataCard_dateLine_item">
                <div class="info_dataCard_dateLine_item_lable">答疑数量</div>
                <div class="info_dataCard_dateLine_item_value">
                  {{
                    workData && workData.totalExamMarkNum
                      ? workData.totalExamMarkNum
                      : "--"
                  }}<span></span>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
    <!-- 评价 -->
    <div class="titleLineGreen" style="margin-top: 40px">评价</div>

    <el-form
      style="margin-top: 20px"
      :model="queryParams"
      ref="queryForm"
      size="small"
      :inline="true"
      label-width="80px"
    >
      <el-form-item label="学生" prop="name">
        <el-input
          v-input-restrict
          style="width: 150px"
          v-model="queryParams.name"
          placeholder="请输入学生名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="班级" prop="classId">
        <el-select
          style="width: 150px"
          filterable
          v-model="queryParams.classId"
          placeholder="请选择"
          clearable
        >
          <el-option
            v-for="item in classes"
            :key="item.classId"
            :label="item.className"
            :value="item.classId"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="评价" prop="minNum" v-if="showSearch">
        <el-input
          v-input-restrict-number
          @input="handleInputNumberChange1"
          :precision="0"
          style="width: 100px !important"
          :min="0"
          :max="5"
          controls-position="right"
          v-model="queryParams.minNum"
          placeholder="最低评价"
          clearable
          @keyup.enter.native="handleQuery"
        />
        至
        <el-input
          v-input-restrict-number
          :precision="0"
          @input="handleInputNumberChange2"
          style="width: 100px !important"
          :min="0"
          :max="5"
          controls-position="right"
          v-model="queryParams.maxNum"
          placeholder="最高评价"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="评价时间" prop="classId" v-if="showSearch">
        <el-date-picker
          value-format="yyyy-MM-dd HH:mm:ss"
          v-model="queryParams.date"
          type="daterange"
          align="right"
          unlink-panels
          range-separator="至"
          start-placeholder="开始日期"
          end-placeholder="结束日期"
          :picker-options="$pickerOptions"
        >
        </el-date-picker>
      </el-form-item>
      <el-form-item>
        <el-button
          v-preventReClick
          type="primary"
          icon="el-icon-search"
          size="mini"
          @click="handleQuery"
          >搜索</el-button
        >
        <el-button
          v-preventReClick
          icon="el-icon-refresh"
          size="mini"
          @click="resetQuery"
          >重置</el-button
        >
      </el-form-item>
      <right-toolbar
        style="margin-top: 3px"
        :showSearch.sync="showSearch"
        @queryTable="getList"
      ></right-toolbar>
    </el-form>

    <el-table v-loading="loading" :data="postList">
      <el-table-column label="学生" align="center" prop="name">
        <template slot-scope="scope">
          <div>{{ scope.row.name }}({{ scope.row.user_name }})</div>
        </template>
      </el-table-column>
      <el-table-column label="班级(学院-专业)" align="center" prop="class_name">
        <template slot-scope="scope">
          <div>
            {{ scope.row.class_name }}({{ scope.row.branch_name }}-{{
              scope.row.major_name
            }})
          </div>
        </template>
      </el-table-column>

      <el-table-column
        label="总分"
        align="center"
        prop="total"
        sortable
        width="165"
      >
        <template slot-scope="scope">
          <div style="text-align: left !important">
            <el-rate
              v-model="scope.row.total"
              disabled
              show-score
              text-color="#ff9900"
              score-template="{value}"
            >
            </el-rate>
          </div>
        </template>
      </el-table-column>

      <el-table-column
        label="能力水平"
        align="center"
        prop="ability_star"
        sortable
        width="140"
      >
        <template slot-scope="scope">
          <div>
            <el-rate disabled v-model="scope.row.ability_star"> </el-rate>
          </div>
        </template>
      </el-table-column>
      <el-table-column
        label="敬业精神"
        align="center"
        prop="dedicated_star"
        sortable
        width="140"
      >
        <template slot-scope="scope">
          <div>
            <el-rate disabled v-model="scope.row.dedicated_star"> </el-rate>
          </div>
        </template>
      </el-table-column>
      <el-table-column
        label="教学热情"
        align="center"
        prop="enthusiasm_star"
        sortable
        width="140"
      >
        <template slot-scope="scope">
          <div>
            <el-rate disabled v-model="scope.row.enthusiasm_star"> </el-rate>
          </div>
        </template>
      </el-table-column>
      <el-table-column
        label="评价时间"
        align="center"
        prop="student_evaluate_time"
      >
        <template slot-scope="scope">
          <div>
            {{ parseTime(scope.row.student_evaluate_time) }}
          </div>
        </template>
      </el-table-column>
      <el-table-column
        label="操作"
        align="center"
        class-name="small-padding fixed-width"
      >
        <template slot-scope="scope">
          <el-button
            v-preventReClick
            size="mini"
            type="text"
            icon="el-icon-view"
            @click="handleDetail(scope.row)"
            >详情</el-button
          >
        </template>
      </el-table-column>
    </el-table>
    <teacherDetailDia :open.sync="open" :item="item"></teacherDetailDia>
  </div>
</template>

<script>
import { listPost } from "@/api/system/post";
import teacherDetailDia from "./components/teacherDetailDia";
import {
  getPost_teacher,
  teacherInfoAndWorkInfo,
  getStuAppraise,
} from "@/api/schoolOrganization/teacher";
import { listPost_class } from "@/api/schoolOrganization/organization";
export default {
  components: { teacherDetailDia },
  dicts: ["sys_course_type"],
  props: {},
  data() {
    return {
      open: false,
      item: {},
      // 遮罩层
      loading: false,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: false,
      // 总条数
      total: 0,
      // 岗位表格数据
      postList: [],
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 9999,
        workstationId: undefined,
        classId: undefined,
        date: undefined,
        minNum: 0,
        maxNum: 5,
      },
      info: {},
      responsibleData: {},
      workData: {},
      classes: [],
    };
  },
  watch: {
    "queryParams.minNum": function (val) {
      console.log(val);
    },
  },
  methods: {
    handleDetail(item) {
      this.open = true;
      this.item = item;
    },
    async getClasses() {
      let res = await listPost_class();
      this.classes = res.rows;
    },
    handleInputNumberChange1(value) {
      if (value > this.queryParams.maxNum) {
        this.$nextTick(() => {
          this.$set(this.queryParams, "minNum", this.queryParams.maxNum);
        });
      }
    },
    handleInputNumberChange2(value) {
      if (value < this.queryParams.minNum) {
        this.$nextTick(() => {
          this.$set(this.queryParams, "maxNum", this.queryParams.minNum);
        });
      }
    },
    getList() {
      this.loading = true;
      this.queryParams.teacherId = this.$route.query.teacherId;
      this.queryParams.begin = this.queryParams.date
        ? this.queryParams.date[0]
        : "";
      this.queryParams.end = this.queryParams.date
        ? this.queryParams.date[1]
        : "";
      delete this.queryParams.date;
      getStuAppraise(this.queryParams).then((response) => {
        this.postList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    /* 获取工作详细信息 */
    async getTeacherInfoAndWorkInfo() {
      let res = await teacherInfoAndWorkInfo(this.$route.query.teacherId);
      this.info = res.data.baseInfo;
      this.responsibleData = res.data.responsibleData;
      this.workData = res.data.workData;
    },
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.queryParams.minNum = 0;
      this.queryParams.maxNum = 5;
      this.handleQuery();
    },
  },
  created() {},
  mounted() {
    this.getClasses();
    this.getTeacherInfoAndWorkInfo();
    this.getList();
  },
};
</script>
<style scoped lang="scss">
.info.flex {
  margin: 23px 0 0 0;
  .info_avatar {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    box-sizing: border-box;
    border: 1px solid rgba(229, 229, 229, 1);
    margin: 0 24px 0 10px;
  }

  .info_right {
    .info_teacherinfos {
      .info_teacherinfo_line_item {
        box-sizing: border-box;
        padding-right: 25px;
        width: 276px;
        font-size: 14px;
        font-weight: 400;
        line-height: 20px;
        color: rgba(96, 98, 102, 1);
        .info_teacherinfo_line_item_nickname {
          font-size: 18px;
          font-weight: 600;
          line-height: 20px;
          color: rgba(51, 51, 51, 1);
          max-width: 227px;
        }
        .sex {
          margin: 5px 0 0 5px;
          width: 12px;
          height: 12px;
        }
      }
      .info_teacherinfo_line1 {
        margin-top: 3px;
      }
      .info_teacherinfo_line2 {
        margin-top: 15px;
      }
    }

    .info_dataCards {
      margin-top: 22px;
      .info_dataCard {
        height: 112px;
        border-radius: 8px;
        background: rgba(255, 255, 255, 1);
        box-shadow: 0px 0px 12px rgba(99, 99, 99, 0.14);
        box-sizing: border-box;
        padding: 16px 0 0 20px;
        .info_dataCard_topLine.flex {
          .info_dataCard_topLine_point {
            margin: 5px 8px 0 0;
            width: 10px;
            height: 10px;
            border-radius: 5px;
          }
          .info_dataCard_topLine_lable {
            font-size: 14px;
            font-weight: 600;
            line-height: 20px;
            color: rgba(51, 51, 51, 1);
            span {
              margin: 4px 0 0 0;
              font-size: 10px;
              font-weight: 400;
              line-height: 14px;
              color: rgba(51, 51, 51, 1);
            }
          }
        }
        .info_dataCard_dateLine2 {
          .info_dataCard_dateLine_item:last-of-type {
            width: 60px !important;
          }
        }
        .info_dataCard_dateLine1 {
          .info_dataCard_dateLine_item:last-of-type {
            width: 92px !important;
          }
        }
        .info_dataCard_dateLine.flex {
          margin-top: 20px;
          .info_dataCard_dateLine_item {
            width: 100px;
            .info_dataCard_dateLine_item_lable {
              font-size: 12px;
              font-weight: 400;
              line-height: 17px;
              color: rgba(153, 153, 153, 1);
            }

            .info_dataCard_dateLine_item_value {
              margin-top: 4px;
              font-size: 18px;
              font-weight: 600;
              line-height: 25px;
              color: rgba(238, 62, 62, 1);
              span {
                margin: 4px 0 0 0;
                font-size: 12px;
                font-weight: 400;
                line-height: 16px;
                color: rgba(51, 51, 51, 1);
              }
            }
          }
        }
      }
    }
  }
}
</style>
